<template>
	<div class="layout-pd">
		<section v-show="status === 1">
			<el-card shadow="hover">
				<el-form :model="state.param"  label-width="100px">
					<el-row :gutter="35">
						<el-col :xs="22" :sm="22" :md="22" :lg="22" :xl="22">
							<el-row :gutter="35">
								<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" class="mb20">
									<el-form-item label="商品品牌">
										<el-select v-model="state.param.brand" placeholder="请选择商品品牌" class="w100">
											<el-option v-for="item in state.query.brandList" :key="item.value" :label="item.label"
												:value="item.value" />
										</el-select>
									</el-form-item>
								</el-col>

								<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" class="mb20">
									<el-form-item label="属性">
										<el-select v-model="state.param.property" placeholder="请选择属性" class="w100">
											<el-option v-for="item in state.query.propertyList" :key="item.value" :label="item.label"
												:value="item.value" />
										</el-select>
									</el-form-item>
								</el-col>

								<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" class="mb20">
									<el-form-item label="入库方式">
										<el-select v-model="state.param.warehouse" placeholder="请选择入库方式" class="w100">
											<el-option v-for="item in state.query.inWarehouseList" :key="item.value" :label="item.label"
												:value="item.value" />
										</el-select>
									</el-form-item>
								</el-col>

							
								
								<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
									<el-form-item label="输入搜索">
										<el-input v-model="state.param.name" placeholder="商品ID/商品名称/名称首字母/条形码" clearable></el-input>
									</el-form-item>
								</el-col>

								<el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" class="mb20">
									<el-form-item label="入库时间">
										<el-date-picker v-model="state.param.dateTime" type="daterange" unlink-panels :shortcuts="shortcuts"
											format="YYYY/MM/DD" value-format="YYYY-MM-DD" range-separator="-" :disabled-date="disabledDate"
											start-placeholder="开始日期" end-placeholder="结束日期" />
									</el-form-item>
								</el-col>
							</el-row>
						</el-col>
						<el-col :xs="2" :sm="2" :md="2" :lg="2" :xl="2" class="screenMenu">
							<el-button type="primary" @click="search">
								<SvgIcon name="iconfont icon-biaodan" /> 搜 索
							</el-button>
							<el-button type="primary" @click="setStatus(2)" style="margin: 20px 0 0 0;">
								<SvgIcon name="iconfont icon-biaodan" /> 入 库
							</el-button>
						</el-col>
					</el-row>
				</el-form>
			</el-card>

			<el-card shadow="hover" class="mt15" v-loading="state.loading">
				<el-table :data="state.tableData" style="width: 100%"> 
					<el-table-column label="批次号" prop="cardItemName" />
					<el-table-column label="SKU-ID" prop="cardItemName" />
					<el-table-column label="品牌" prop="cellPrice" />
					<el-table-column label="商品名称" prop="orderPrice" />
					<el-table-column label="属性" prop="cellPrice" />
					<el-table-column label="规格" prop="buyCount"  />
					<el-table-column label="条形码" prop="buyCount"  />
					<el-table-column label="入库方式" prop="buyCount"  />
					<el-table-column label="数量" prop="buyCount"  />
					<el-table-column label="保质期至" prop="buyCount"  />
					<el-table-column label="操作人员" prop="buyCount"  />
					<el-table-column label="时间" prop="buyCount"  />
					<el-table-column label="备注" prop="buyCount"  />
					
				</el-table>

				<section class="mt15">
					<el-row justify="end">
						<el-col :span="24" class="flex-end-center">
							<el-pagination
							v-model:current-page="state.param.pageNum"
							v-model:page-size="state.param.pageSize"
							:page-sizes="[10, 20, 30]"  
							:background="true"
							layout="total, sizes, prev, pager, next, jumper"
							:total="state.param.total"
							@size-change="handleSizeChange"
							@current-change="handleCurrentChange"
							/>
						</el-col>
					</el-row> 
				</section>
			</el-card>
		</section>
		<section v-show="status === 2">
			<el-card shadow="hover" class="mt15" v-loading="state.loading">
				<AddLibs :setStatus="setStatus" />
			</el-card>
		</section>
		
	</div>
</template>

<script setup lang="ts" name="funCountup">
import {  onMounted, reactive, ref } from 'vue';

import AddLibs from './components/AddLibs.vue' 

import type { storeNodeListData, channelListData } from "/@/types/order";
const status = ref<1 | 2 | 3>(1)
const state = reactive({
	dialogTitle: '',
	param: {
		dateTime: '',
		warehouse: 1,
		total: 0,
		keyword: "",
		pageNum: 1,
		pageSize: 10,
		rowId: 0,
		brand: '',
		property: '',
		name: ''
	},
	query: {
		brandList: [
			{ value: 1, label: '美云狐' },
			{ value: 2, label: '红豆' },
		], 
		inWarehouseList: [
			{ value: 1, label: '全部' },
			{ value: 2, label: '入库' },
			{ value: 3, label: '盘库' },
			{ value: 4, label: '发货' },
		], 
		propertyList: [
			{ value: 1, label: '全部' },
			{ value: 2, label: '家居' },
			{ value: 3, label: '套盒' },
		]
	},
	loading: false,
	total: 0,
	tableData: [
		{
			id: 1,
			cardItemName: '测试',
			property: '属性名称',
			spec: '规格',
			salesVolume: '销量',
			cellPrice: '销售价格', 
			orderPrice: '销售金额',
			buyCount: '购买人数',
			coverRatio: '客户覆盖率',
			performanceRatio: '业绩占比',
			allRatio: '全款率',
			startTime: '2023-12-22 12:36:54',
			endTime: '2023-12-22 12:36:54', 
			status: '活动状态',
		}
	] as Array<any>
		
});

const cardDialogVisble = ref(false)
const defaultTime2: [Date, Date] = [
  new Date(2000, 1, 1, 12, 0, 0),
  new Date(2000, 2, 1, 8, 0, 0),
]

const search = () => {}

const handleSizeChange = () => {}
const handleCurrentChange = () => {}
const previewInfo = (row: any) => {
	state.param.rowId = row.id
	cardDialogVisble.value = true
	state.dialogTitle = row.cardItemName || ''
}

const disabledDate= (time: Date) => time.getTime() > Date .now();

const shortcuts = [
	{
		text: '本月',
		value: () => {
		const end = new Date()
		const start = new Date()
		start.setTime(start.setDate(1))
		return [start, end]
		},
	},
	{
		text: '近一个月',
		value: () => {
		const end = new Date()
		const start = new Date()
		start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
		return [start, end]
		},
	},
	{
		text: '近三个月',
		value: () => {
		const end = new Date()
		const start = new Date()
		start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
		return [start, end]
		},
	},
	{
		text: '近半年',
		value: () => {
		const end = new Date()
		const start = new Date()
		start.setTime(start.getTime() - 3600 * 1000 * 24 * 180)
		return [start, end]
		},
	},
	{
		text: '近一年',
		value: () => {
		const end = new Date()
		const start = new Date()
		start.setTime(start.getTime() - 3600 * 1000 * 24 * 365)
		return [start, end]
		},
	},
]
 
const setStatus = (num: 1 | 2 | 3) => status.value = num;

// 页面加载时
onMounted(() => {
});
</script>

<style scoped lang="scss">
</style>
